#include "libsocialbox/web_client.hpp"
#include "libsocialbox/google_reader.hpp"
#include "test_app.hpp"

#include <QWidget>
#include <QBuffer>
#include <QDebug>
#include <QFile>

#include <QPushButton>
#include <QVBoxLayout>

TestApp::TestApp(QWidget *parent)
     : QDialog(parent)
{
    gr = new GoogleReader("test.socialbox", "S0ci@lB0x", WebClient::Asynchronous);
    downloadButton = new QPushButton(tr("Download"));

    connect(gr, SIGNAL(loginFinished(int)), this, SLOT(finished(int)));
    connect(downloadButton, SIGNAL(clicked()), this, SLOT(test()));

    QVBoxLayout *mainLayout = new QVBoxLayout;

    mainLayout->addWidget(downloadButton);
    setLayout(mainLayout);
}

TestApp::~TestApp()
{
    delete gr;
    delete downloadButton;
}

void TestApp::test()
{
    gr->login();
    /*
    output = new QFile("data.jpg");
    output2 = new QFile("data.html");
    output->open(QFile::WriteOnly);
    output2->open(QFile::WriteOnly);
    qDebug() << "Search" << wc->get("http://www.google.com/search?q=socialbox", output2);
    qDebug() << "Associated buffer::"<< output2;
    qDebug() << "JPG" << wc->get("http://kitsunenoir.com/dwpimages/cleon-peterson-1024x768.jpg", output);
    qDebug() << "Associated buffer::"<< output;
    */
}

void TestApp::finished(int status)
{

    qDebug() << "Login status: " << status;
}
